#include <iostream>
#include <cmath>
using namespace std;
//嵌套类：外部类Line和内部类Point
//比如有的场景下，某个类只希望被特定的类访问，其他类不能够访问或者使用
//这个时候就可以将其设计为嵌套类
//比如Line和Point，如果不希望外部去访问Point类对象，那么直接设计成嵌套类

class Line{
    public:
        Line(int a,int b,int c,int d)
        :_pt1(a,b)
        ,_pt2(c,d)
        {    cout<<"("<<a<<","<<b<<")"
                <<"--------->"
                <<"("<<c<<","<<d<<")"
                <<endl;
        }
        friend class Point;
        void display(){
            cout<<"Point::print()"<<endl;
        }
        class Point{
        public:
            Point(int a,int b)
            :_a(a)
            ,_b(b)
            {
                cout<<a<<","<<b<<endl;
            }
            friend ostream &operator<<(ostream &os,const Line::Point& rhs); 
            void print(){
                cout<<"Line::Point::print()"<<endl;
            }
            friend class Line;
            
        private:
            int _a,_b;
        };

        int test(){
        int dx=_pt1._a-_pt2._a;
        int dy=_pt1._b-_pt2._b;
        return sqrt(dx*dx+dy*dy);
        }
    private:
        Point _pt1;
        Point _pt2;
};
ostream & operator<<(ostream& os,const Line::Point & rhs){
    os<<rhs._a<<rhs._b;
    return os;
}
void test(){
    Line l(1,2,3,4);
    Line::Point point(1,2);
    int a=l.test();
    cout<<a<<endl;
    cout<<point<<endl;
}
int main(int argc, char * argv[]){
    test();
    return 0;
}

